import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { LayuiVueResolver } from 'unplugin-vue-components/resolvers';
import WindiCSS from 'vite-plugin-windicss';
import cesium from 'vite-plugin-cesium';


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue({reactivityTransform: true,}),
    WindiCSS(),
    cesium({rebuildCesium: true}),
    AutoImport({
      resolvers: [LayuiVueResolver()],
    }),
    Components({
      resolvers: [LayuiVueResolver()],
    })
  ],
 
  base: './',
  outDir: 'dist',
  server: {
    open: true, 
    port: 8989, //端口号
    https: false, // 是否开启 https
    ssr: false, // 服务端渲染
    proxy: {      
      '/api': {
        target: "http://192.168.10.233:18890",
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '') // 去掉 /api 前缀
      },
      '/jz':{
        target: "http://125.46.5.250:9736",
        changeOrigin: true,
        rewrite: path => path.replace(/^\/jz/, '') 
      }
    }
  }
})


